<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>数组 </title>
</head>
<body>
        <script>
            window.onload = function(){
                console.log(1)
                
                var changeArr = function (arr, oldIndex, newIndex) {
                    var temp = arr[oldIndex];
                    if(oldIndex > newIndex){
                        arr.splice(oldIndex,1)
                        console.log(`> temp: ${arr}`)
                        arr.splice(newIndex, 0, temp)
                    } else if(oldIndex < newIndex){
                        if(newIndex === arr.length){
                            arr.splice(oldIndex, 1)
                            arr.push(temp)
                        } else {
                            arr.splice(newIndex,0, temp)
                            arr.splice(oldIndex, 1)
                        }
                    }
                    return arr
                }
                console.log(changeArr([0,1,2,3,4,5,6,7], 7, 0))
            }
            </script>
    
</body>
</html>